import 'package:jpush_flutter/jpush_flutter.dart';
class JPushTool {
  JPush jpush;
  JPushTool(){
    jpush = new JPush();
  }

  push(String title,String content,String subtitle){
    var fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000);
    var localNotification = LocalNotification(
      id: 234,
      title: title,
      buildId: 1,
      content: content,
      fireTime: fireDate,
      subtitle: subtitle, // 该参数只有在 iOS 有效
      badge: 5, // 该参数只有在 iOS 有效
//          extras: {"fa": "0"} // 设置 extras ，extras 需要是 Map<String, String>
    );
    jpush.sendLocalNotification(localNotification).then((res) {});
//    print("推送");
  }
  //初始化极光推送
  init(){
    jpush.getRegistrationID().then((rid) {
//      print(rid);
    });
    jpush.setup(
      appKey: "76167a0f2055efa8e72c66b2",
      channel: "theChannel",
      production: false,
      debug: false, // 设置是否打印 debug 日志
    );
    jpush.addEventHandler(
      // 接收通知回调方法。
      onReceiveNotification: (Map<String, dynamic> message) async {
//        print("flutter onReceiveNotification: $message");
      },
      // 点击通知回调方法。
      onOpenNotification: (Map<String, dynamic> message) async {
//        print("flutter onOpenNotification: $message");
      },
      // 接收自定义消息回调方法。
      onReceiveMessage: (Map<String, dynamic> message) async {
//        print("flutter onReceiveMessage: $message");
      },
    );

  }

}